import QtQuick
import QtQuick.Particles

Rectangle {
    width: 400
    height: 400
    color: "black"

    ParticleSystem {
        id: particleSystem
    }

    // g1组粒子的样式 - 较大的粒子
    ItemParticle {
        system: particleSystem
        groups: ["g1"]
        delegate: Rectangle {
            width: 18
            height: 18
            radius: 9
            color: "#00ffff"
        }
    }

    // g2组粒子的样式 - 较小的粒子
    ItemParticle {
        system: particleSystem
        groups: ["g2"]
        delegate: Rectangle {
            width: 6
            height: 6
            radius: 3
            color: "#00ffff"
        }
    }

    // 中心发射器
    Emitter {
        system: particleSystem
        group: "g1"
        anchors.centerIn: parent
        width: 1
        height: 1
        emitRate: 3
        lifeSpan: 1000
        size: 16

        velocity: AngleDirection {
            angle: 0
            angleVariation: 360
            magnitude: 120
            magnitudeVariation: 40
        }
    }

    // 尾迹发射器
    TrailEmitter {
        id: trailEmitter
        system: particleSystem
        follow: "g1"
        group: "g2"
        emitRatePerParticle: 10
        lifeSpan: 500
        size: 8
        endSize: 0
    }

    Text {
        anchors.top: parent.top
        anchors.horizontalCenter: parent.horizontalCenter
        color: "white"
        text: "扩散粒子与尾迹效果"
        font.pixelSize: 16
        padding: 10
    }
} 
